package formulation;

public class UnitConvertor
{
    static public Double changeToBaseUnit(String unit, Double value) {
        if (unit.equals("ug")) {
            return value;
        }
        else if (unit.equals("mg")) {
            return 1000 * value;
        }
        else if (unit.equals("g")) {
            return 1000000 * value;
        }
        return value;
    }
    
    static public Double changeFromBaseUnit(String unit, Double value) {
        if (unit.equals("ug")) {
            return value;
        }
        else if (unit.equals("mg")) {
            return value / 1000;
        }
        else if (unit.equals("g")) {
            return value / 1000000;
        }
        return value;
    }
}
